package com.wsc.strategy;

import java.util.Arrays;
import java.util.Comparator;

public class Main {
    public static void main(String[] args) {
        Cat[] arr = {new Cat(3, 3, 3),new Cat(7, 7, 7)
                ,new Cat(1, 1, 1)};

        // 用 Lambda 表达式来完成实现，不用再单独写一个类,比较方便
        Comparator<Cat> heightCompare = (Cat a,Cat b)->{
            if (a.getHeight() < b.getHeight()) return -1;
            else return a.getHeight() > b.getHeight() ? 1:0;
        };

        Sorter<Cat> sorter = new Sorter<Cat>();
        sorter.sort(arr,heightCompare);
        System.out.println(Arrays.toString(arr));
    }
}
